import PageA from './pages/user/a.vue' // vue组件的引入 需要写完整路径 需要包含.vue扩展
import PageB from './pages/user/b.vue'
import Order from './pages/shop/OrderAndPay.vue'

import Admin from './pages/admin/Admin.vue'
import User from './pages/User/User.vue'
import Shop from './pages/Shop/Shop.vue'
import ShopSearch from './pages/shop/Search.vue'

// 路由配置文件

const routes = [
    {
        path: '/',
        component: Shop,
        children: [
            // 商城子页面
            {path: '/', component: ShopSearch},
            {path: '/search', component: ShopSearch},
            {path: '/pay', component: Order},
        ]
    },
    {
        path: '/',
        component: User,
        children: [
            {path: '/user/login', component: PageA},
            {path: '/user/reg', component: PageB},
        ]
    },
    {
        path: '/admin',  // 这是页面对应的访问路径 /表示首页
        component: Admin  // 对应对应的vue组件
    },
]
// 创建路由信息管理器
// 3.x
// import VueRouter from 'vue-router'
// 老版本写法
// const router = new VueRouter({
//     routes
// });

import {createWebHashHistory, createRouter} from 'vue-router'
// 4.x
// 直接创建一个路由器
const router = createRouter({
    history: createWebHashHistory(), // 使用hash的模式
    routes,
})

// 暴露路由器
export default router